﻿//-------------------------------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2011 , JamSoft TECH, Ltd .
//-------------------------------------------------------------------------------------
using System;

// 本系统生成的类库
using DotNet.Business;
using DotNet.Utilities;

/// <remarks>
/// UserStatistics
/// 用户状态信息
/// 
/// 修改纪录
/// 
///	版本：1.0 2011.08.27 LiangMingMing  创建代码。 
/// <author>
///		<name>LiangMingMing</name>
///		<date>2011.08.27</date>
/// </author> 
/// </remarks>
public partial class UserStatistics : BasePage
{
    // **********************************************************************************************
    // *                                                                                            * 
    // *                             Public Variate    公共变量                                     *
    // *                                                                                            * 
    // **********************************************************************************************

    /// <summary>
    /// 多语言变量（添加到收藏夹）
    /// </summary>
    public string ToolbarFavorite = string.Empty;
    /// <summary>
    /// 多语言变量（显示隐藏左边菜单）
    /// </summary>
    public string ToolbarShowhideLeftFrame = string.Empty;
    /// <summary>
    /// 多语言变量（显示隐藏TOP页面）
    /// </summary>
    public string ToolbarShowhideTopFrame = string.Empty;
    /// <summary>
    /// 多语言变量（帮助中心）
    /// </summary>
    public string ToolbarHelp = string.Empty;

    // **********************************************************************************************
    // *                                                                                            * 
    // *                             InitializeComponent  初始化                                    * 
    // *                                                                                            * 
    // **********************************************************************************************

    #region private void PageOnLoad() 页面初次加载时的动作
    /// <summary>
    /// 页面初次加载时的动作
    /// </summary>
    private void PageOnLoad()
    {
        try
        {
            // 打开数据库连接
            this.UserCenterDbHelper.Open();
            // 获取统计情况
            this.GetUserCount();
        }
        catch (Exception ex)
        {
            // 记录日志
            this.LogException(ex);
            // 抛出异常
            throw ex;
        }
        finally
        {
            // 关闭数据库连接
            this.UserCenterDbHelper.Close();
        }
    }
    #endregion

    // **********************************************************************************************
    // *                                                                                            * 
    // *                                       Method   操作方法                                    * 
    // *                                                                                            * 
    // **********************************************************************************************

    #region private void Localization() 多语言国际化加载
    /// <summary>
    /// 多语言国际化加载
    /// </summary>
    private void Localization()
    {
        // 多语言国际化加载
        ResourceManagerWrapper.Instance.LoadResources(Server.MapPath("../../../../Resource/Localization/"));
        // 获取语言信息
        this.GetLanguageResource(Utilities.GetCurrentLanguage(this.UserInfo));
    }
    #endregion

    #region private void GetLanguageResource(string languages) 获取语言
    /// <summary>
    /// 获取语言
    /// </summary>
    /// <param name="languages">语言类型</param>
    private void GetLanguageResource(string languages)
    {
        // 添加到收藏夹
        this.ToolbarFavorite = ResourceManagerWrapper.Instance.Get(languages, "Toolbar.Favorite");
        // 显示隐藏左边菜单
        this.ToolbarShowhideLeftFrame = ResourceManagerWrapper.Instance.Get(languages, "Toolbar.ShowhideLeftFrame");
        // 显示隐藏TOP页面
        this.ToolbarShowhideTopFrame = ResourceManagerWrapper.Instance.Get(languages, "Toolbar.ShowhideTopFrame");
        // 帮助中心
        this.ToolbarHelp = ResourceManagerWrapper.Instance.Get(languages, "Toolbar.Help");
        // 标题
        this.Title = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx");
        // 半年内登录
        this.ltlBanNianNeiDengLu.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlBanNianNeiDengLu");
        // 半年内注册
        this.ltlBanNianNeiZhuCe.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlBanNianNeiZhuCe");
        // 今天登录
        this.ltlJinTianDengLu.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlJinTianDengLu");
        // 今天注册
        this.ltlJinTianZhuCe.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlJinTianZhuCe");
        // 统计日期
        this.ltlTongJiRiQi.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlTongJiRiQi");
        // 一个月内登录
        this.ltlYiGeYueNeiDengLu.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYiGeYueNeiDengLu");
        // 一个月内注册
        this.ltlYiGeYueNeiZhuCe.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYiGeYueNeiZhuCe");
        // 一年内注册
        this.ltlYiNaiNeiZhuCe.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYiNaiNeiZhuCe");
        // 一年内登录
        this.ltlYiNianNeiDengLu.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYiNianNeiDengLu");
        // 一周内登录
        this.ltlYiZhouNeiDengLu.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYiZhouNeiDengLu");
        // 一周内注册
        this.ltlYiZhouNeiZhuCe.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYiZhouNeiZhuCe");
        // 用户登录情况
        this.ltlYongHuDengLuQingKuangTongJi.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYongHuDengLuQingKuangTongJi");
        // 用户统计
        this.ltlYongHuTongJi.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYongHuTongJi");
        // 用户注册情况统计
        this.ltlYongHuZhuCeQingKuangTongJi.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlYongHuZhuCeQingKuangTongJi");
        // 在线
        this.ltlZaiXian.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlZaiXian");
        // 注册用户数
        this.ltlZhuCeYongHuShu.Text = ResourceManagerWrapper.Instance.Get(languages, "UserStatistics.aspx_ltlZhuCeYongHuShu");
    }
    #endregion

    #region private void GetUserCount() 获取统计情况
    /// <summary>
    /// 获取统计情况
    /// </summary>
    private void GetUserCount()
    {
        this.lblTongJiRiQi.Text = DateTime.Now.ToString(BaseSystemInfo.DateFormat);

        BaseUserManager userManager = new BaseUserManager(this.UserCenterDbHelper, this.UserInfo);
        this.lblZaiXian.Text = userManager.GetOnLineCount();
        this.lblJinTianDengLu.Text = userManager.GetLogOnCount(1);
        this.lblYiZhouNeiDengLu.Text = userManager.GetLogOnCount(7);
        this.lblYiGeYueNeiDengLu.Text = userManager.GetLogOnCount(30);
        this.lblBanNianNeiDengLu.Text = userManager.GetLogOnCount(180);
        this.lblYiNianNeiDengLu.Text = userManager.GetLogOnCount(365);

        this.lblZhuCeYongHuShu.Text = userManager.GetCount();
        this.lblJinTianZhuCe.Text = userManager.GetRegistrationCount(1);
        this.lblYiZhouNeiZhuCe.Text = userManager.GetRegistrationCount(7);
        this.lblYiGeYueNeiZhuCe.Text = userManager.GetRegistrationCount(30);
        this.lblBanNianNeiZhuCe.Text = userManager.GetRegistrationCount(180);
        this.lblYiNaiNeiZhuCe.Text = userManager.GetRegistrationCount(365);
    }
    #endregion

    // **********************************************************************************************
    // *                                                                                            * 
    // *                                       EventArgs    事件方法                                * 
    // *                                                                                            * 
    // ********************************************************************************************** 

    #region protected void Page_Load(object sender, EventArgs e) 页面初次加载的动作
    /// <summary>
    /// 页面初次加载的动作
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        // 多语言国际化加载
        this.Localization();
        if (!Page.IsPostBack)
        {           
            // 页面初次加载时的动作
            this.PageOnLoad();
        }
    }
    #endregion
}